package org.firebug.spring.boot.transaction.repository.dao;

import org.apache.ibatis.annotations.*;
import org.firebug.spring.boot.transaction.repository.po.AccountPO;

@Mapper
public interface AccountDAO {
    @Options(useGeneratedKeys = true)
    @Insert("insert into t_account (name,balance) values (#{name},#{balance})")
    int insertAutoIncrement(AccountPO po);

    @Update("update t_account set balance=balance+#{balance} where id=#{id}")
    int increaseBalanceById(@Param("id")int id, @Param("balance") double balance);

    @Update("update t_account set balance=balance-#{balance} where id=#{id}")
    int decreaseBalanceById(@Param("id")int id, @Param("balance") double balance);

    @Select("select * from t_account where id=#{id}")
    AccountPO selectById(@Param("id") int id);
}